<template>
  <div id="app">
  <!-- 头部导航 -->
  <header class="header">
  <el-row>
   <el-col :span="24">
   </el-col>
  </el-row>
  </header>
  <div style="position: relative;height: 60px;width: 100%;"></div>
  <main>
    <!-- 左侧导航 -->
   <div class="main-left">
    <el-menu default-active="/user" class="el-menu-vertical-demo" :router="true">
    <el-menu-item index="/user">用户</el-menu-item>
    <el-menu-item index="/commodity">商品</el-menu-item>
    <el-menu-item index="/commoditylists">商品目录</el-menu-item>
    <el-menu-item index="/custom">客服</el-menu-item>
    <el-menu-item index="/order">订单</el-menu-item>
    <el-menu-item index="/notice">公告</el-menu-item>
    </el-menu>
   </div>
    <!-- 右侧主内容区 -->
    <div class="main-right" >
          <!-- 视图 -->
    <router-view class="view"></router-view>
    </div>
  </main>
  </div>
 </template>
 <script>
export default {
    created: function() {
        this.$axiosPost(
            "/AdminService/isInstalled",
            {},
            response => {
                if (response.data.isInstalled) {
                    if (this.admin && this.admin.session) {
                        this.$axiosPost(
                            "/AdminService/loginBySession",
                            { session: this.admin.session },
                            res => {
                                this.$persistence.put("admin", res.data);
                                this.$clearData();
                                this.$router.push("/");
                            },
                            error => {
                                this.$router.push("/login");
                            }
                        );
                    } else {
                        this.$router.push("/login");
                    }
                } else {
                    this.$router.push("/register");
                }
            },
            error => {
                this.$message.error("连接失败，请检查网络环境！");
            }
        );
    },
    data: function() {
        return {
            admin: this.$persistence.get("admin")
        };
    }
};
</script>
 <style>
body {
    margin: 0;
}
#main {
    min-width: 1200px;
    margin: 0 auto;
    font-family: "Helvetica Neue", "PingFang SC", Arial, sans-serif;
}
/* 头部导航 */
header {
    z-index: 1000;
    min-width: 1200px;
    transition: all 0.5s ease;
    border-top: solid 4px #3091f2;
    background-color: #fff;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12), 0 0 6px 0 rgba(0, 0, 0, 0.04);
}
header.header-fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
}
header .el-menu-demo {
    padding-left: 300px !important;
}
/* 主内容区 */
main {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    min-height: 800px;
    border: solid 2px #e9ecf1;
    background-color: #fcfcfc;
}
main .main-left {
    text-align: center;
    width: 200px;
    float: left;
}
main .main-right {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    background-color: #fff;
    padding: 50px 70px;
}
main .el-menu {
    background-color: transparent !important;
}
</style>
